#ifndef MYTCPSOCKET_H
#define MYTCPSOCKET_H

#include "MessageType.h"
#include <QTcpSocket>

class MyTcpSocket : public QTcpSocket
{
    Q_OBJECT
public:
    MyTcpSocket(QObject *parent = nullptr);

    void sendTLV(TaskType type, int len, const QByteArray &msg);
    void readPacket();

private:
    int sendn(QByteArray buf, int len);
    int recvn(char *buf, int len);
    void clear();

signals:
    void readPacketFinished(Packet m_recvPacket);
    void readyReadMyTcpSocket();

private:
    int m_expectedBodySize = 0;//当前期望读取的内容长度
    Packet m_packet;//用来接收用这个包
};

#endif // MYTCPSOCKET_H
